<template>
  <div>
    <el-row class="art-item" v-for="article in articleList" :key="article.id">
      <el-card shadow="hover">
        <h5>
          <router-link
            :to="'/article/' + article.id"
            tag="span"
            class="art-title"
            >{{ article.title }}
        </router-link>
        </h5>
        <el-row
          class="art-info d-flex align-items-center justify-content-start"
        >
          <div class="art-time">
            <i class="el-icon-time"></i>
            ：{{ article.createTime }}
          </div>
          <div class="d-flex align-items-center" v-if="article.tags != null">
            <img class="tag" src="../assets/images/tag.png" />：
            <el-tag
              size="mini"
              v-for="tag in tagSplit(article.tags)"
              :key="tag"
            >
              {{ tag }}
            </el-tag>
          </div>
        </el-row>
        <el-row class="art-body">
          <div class="side-img hidden-sm-and-down" v-if="article.cover != null">
            <img class="art-banner" src="../assets/images/vue.jpg" />
          </div>
          <div class="side-abstract">
            <div class="art-abstract">
              {{ article.text }}
            </div>
            <div class="art-more">
              <router-link :to="'/article/'+ article.id" tag="span">
                <el-button plain>{{ $t("home.readMore") }}</el-button>
              </router-link>
              <div class="view"><i class="el-icon-view"></i>12414</div>
            </div>
          </div>
        </el-row>
      </el-card>
      <img class="star" src="../assets/images/star.png" v-if="article.top == '1' "/>
    </el-row>
    
  </div>
</template>

<script>
export default {
  name: "v-article",
  data() {
    return {
    };
  },
  props: ["articleList"],
  methods: {
    // 标签分割处理
    tagSplit(data) {
      if (data == null || data == undefined) {
        return [];
      }
      return data.split(",");
    }
  },
  created() {
      console.log(this.total) 
  }
};
</script>

<style scoped>
#side .item {
  margin-bottom: 30px;
}

.art-item {
  margin-bottom: 30px;
  position: relative;
}

.art-item .star {
  width: 60px;
  height: 60px;
  position: absolute;
  top: 0;
  right: 0;
}

img.tag {
  width: 16px;
  height: 16px;
}

.art-title {
  border-left: 3px solid #f56c6c;
  padding-left: 5px;
  cursor: pointer;
}

.art-title:hover {
  padding-left: 10px;
  color: #409eff;
}

.art-time {
  margin-right: 20px;
}

.art-body {
  display: flex;
  padding: 10px 0;
}

.side-img {
  height: 150px;
  width: 270px;
  overflow: hidden;
  margin-right: 10px;
}

img.art-banner {
  width: 100%;
  height: 100%;
  transition: all 0.6s;
}

img.art-banner:hover {
  transform: scale(1.4);
}

.side-abstract {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.art-abstract {
  flex: 1;
  color: #aaa;
}

.art-more {
  height: 40px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.art-more .view {
  color: #aaa;
}
h5 {
  font-size: 18px;
}
.pagination {
  background-color: #f9f9f9;
}
</style>